package com.wyu.notaryserver.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyu.notaryserver.common.ResponseResult;
import com.wyu.notaryserver.domain.CaseDO;
import com.wyu.notaryserver.service.CaseService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Case;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * (Case)表控制层
 *
 * @author Kyle
 * @since 2025-01-09 17:50:32
 */
@RestController
@RequestMapping("case")
public class CaseController {

/**
 * 服务对象
 */
@Resource
private CaseService caseService;

/**
* 分页查询所有数据
*/
@GetMapping
public ResponseResult page(@RequestParam int current, @RequestParam int size){
        Page<CaseDO> page=new Page<>(current,size);
        return ResponseResult.okResult(this.caseService.page(page));
}

/**
 * 通过主键查询单条数据
 */
@GetMapping("{id}")
public ResponseResult selectOne(@PathVariable Serializable id){
        return ResponseResult.okResult(this.caseService.getById(id));
}

/**
 * 新增数据
 */
@PostMapping
public ResponseResult save(@RequestBody CaseDO caseDO){
        return ResponseResult.okResult(this.caseService.save(caseDO));}

/**
 * 修改数据
 */
@PutMapping
public ResponseResult updateById(@RequestBody CaseDO caseDO){
        return ResponseResult.okResult(this.caseService.updateById(caseDO));}

/**
 * 单条/批量删除数据
 */
@DeleteMapping
public ResponseResult delete(@RequestParam List<Long> id){
        return ResponseResult.okResult(this.caseService.removeByIds(id));}
}

